﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Jw.Web.App_Start
{
    public class BaseController : Controller
    {
        private List<string> _macs = null;
        private List<string> macs
        {
            get
            {
                if (_macs == null)
                {

                    _macs = new List<string>();
                    _macs.Add("00:E0:4C:7C:7B:79"); //xiaoping
                    _macs.Add("6C:71:D9:8B:7F:CC");//无线
                    _macs.Add("74:27:EA:AE:1A:F7");//Host 74-27-EA-AE-1A-F7
                    _macs.Add("C4:54:44:0B:B8:6F"); //192.168.1.7 
                }
                return _macs;
            }
        }

        protected override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            if (!Request.IsLocal)
            {
                //增加授权Mac
                string serverMac = Jw.Utils.Helper.NetHelper.GetMACAddress();
                if (!macs.Contains(serverMac))
                {
                    string error = "该版本程序只能用于开发模式，不可以运行至布署模式！请联系软件开发商.  特征码：" + string.Format("00x{0}x0$", serverMac.Replace(':', '$'));
                    filterContext.Result = new ContentResult() { Content = error };
                }
            }
            base.OnActionExecuted(filterContext);
        }
    }
}